package com.niuke;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * 44. We Are A Team
 * https://blog.csdn.net/weixin_43428283/article/details/127158482
 */
public class NiukeMoni44 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String[] line1 = scanner.nextLine().split(" ");
        int n = Integer.parseInt(line1[0]);
        int m = Integer.parseInt(line1[1]);

        List<String> keys = new ArrayList<>();
        List<Set<Integer>> data = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            String[] line = scanner.nextLine().split(" ");
            String key = line[0] + "-" + line[1];
            int index = keys.indexOf(key);
            if (index < 0) {
                keys.add(key);
                Set<Integer> cs = new HashSet<>();
                cs.add(Integer.parseInt(line[2]));
                data.add(cs);
            } else {
                Set<Integer> cs = data.get(index);
                cs.add(Integer.parseInt(line[2]));
            }
        }

        List<String> result = new ArrayList<>();
        List<Set<Integer>> teams = new ArrayList<>();

        // 第一次循环做分组和粗略结果，结果中用特殊字符表示未确定，对结果做次循环，区分待确定的在同一个team还是不在
        for (int k = 0; k < keys.size(); k++) {
            String key = keys.get(k);
            String[] p = key.split("-");
            int a = Integer.parseInt(p[0]);
            int b = Integer.parseInt(p[1]);
            if (a <= 0 || a > n || b <= 0 || b > n) {
                result.add(key);
                result.add("da pian zi");
                continue;
            }

            Set<Integer> guanXi = data.get(k);
            boolean isNormal = true;
            for (Integer g : guanXi) {
                if (g < 0 || g > 1) {
                    result.add(key);
                    result.add("da pian zi");
                    isNormal = false;
                    break;
                }
            }

            if (isNormal) {
                if (guanXi.contains(0)) {
                    result.add(key);
                    result.add("we are a team");
                    if (teams.size() == 0) {
                        Set<Integer> team = new HashSet<>();
                        team.add(a);
                        team.add(b);
                        teams.add(team);
                    } else {
                        List<Integer> containIndex = new ArrayList<>();
                        for (int i = 0; i < teams.size(); i++) {
                            Set<Integer> team = teams.get(i);
                            if (team.contains(a) || team.contains(b)) {
                                team.add(a);
                                team.add(b);

                                containIndex.add(i);
                            }
                        }

                        if (containIndex.size() > 1) {
                            Set<Integer> newTeam = new HashSet<>();
                            for (int i = containIndex.size(); i >= 0; i--) {
                                newTeam.addAll(teams.get(i));
                                teams.remove(i);
                            }
                            teams.add(newTeam);
                        } else if (containIndex.size() == 0) {
                            Set<Integer> team = new HashSet<>();
                            team.add(a);
                            team.add(b);
                            teams.add(team);
                        }
                    }
                } else {
                    result.add(key);
                    result.add("not sure");
                }
            }

        }


        for (int i = 0; i < result.size() / 2; i++) {
            if (result.get(2 * i + 1).equals("not sure")) {
                String[] p = result.get(2 * i).split("-");
                int a = Integer.parseInt(p[0]);
                int b = Integer.parseInt(p[1]);
                boolean isATeam = false;
                for (int j = 0; j < teams.size(); j++) {
                    Set<Integer> team = teams.get(j);
                    if (team.contains(a) && team.contains(b)) {
                        isATeam = true;
                        System.out.println(result.get(2 * i) + ": we are a team");
                        break;
                    }
                }

                if (!isATeam) {
                    System.out.println(result.get(2 * i) + ": we are not a team");
                }
            } else {
                System.out.println(result.get(2 * i) + ": " + result.get(2 * i + 1));
            }

        }

    }

}
